<template>
  <div>
    <el-card>
      <div slot="header" class="clearfix text-left">
        <el-col :span="23">
          <span class="title-icon">法邮追踪号</span>
        </el-col>
      </div>
      <el-row style="margin-top: 30px;margin-bottom: 30px">
        <el-col :span="1">
          <span>运单号:</span>
        </el-col>
        <el-col :span="6">
          <el-input size="large" :rows="5" v-model="waybillNos" type="textarea"  placeholder="请输入运单号(法国),多个换行隔开"></el-input>
        </el-col>
        <el-col :span="4" style="margin-left: 10px;">
          <el-button size="mini" type="primary" @click="trackPrintlabelChrornopost">获取法邮追踪号</el-button>
        </el-col>
      </el-row>

      <el-row  style="margin-top: 30px;margin-bottom: 50px">
        <el-col :span="1">
          <span>打单帐号:</span>
        </el-col>
        <el-col :span="10">
          <el-select v-model="accountNo"  :rows="10" placeholder="请选择" style="100%">
            <el-option
              v-for="(item, value) in options"
              :key="value"
              :label="item"
              :value="value">
            </el-option>
          </el-select>
        </el-col>
      </el-row>
      <el-row  style="margin-top: 30px;margin-bottom: 50px">
        <el-col :span="1">
          <span>发件人地址:</span>
        </el-col>
        <el-col :span="10">
          <el-select v-model="addressCode"  :rows="10" placeholder="请选择">
            <el-option
              v-for="(item, value) in addressNameMap"
              :key="value"
              :label="item"
              :value="value">
            </el-option>
          </el-select>
        </el-col>
      </el-row>

    </el-card>
  </div>
</template>
<script>
  import { ajax } from "@/store/yg/common/utils";
  import axios from "axios";
  import * as constant from "@/store/yg/common/constant";

  export default {
    components: {},
    props: [],
    data() {
      return {
        waybillNos: '',
        options: [],
        addressCode: '',
        addressNameMap: [],
        accountNo: '',
      };
    },
    computed: {},
    watch: {},
    created() {},
    mounted() {
      this.toGainChrornopostTrack();
    },
    methods: {
      toGainChrornopostTrack(){
        ajax("toGainChrornopostTrack", {}).then(
          res => {
            console.log(res);
            if (res.code == 200) {
              this.options = res.data;
              this.addressNameMap = res.data2;
            }else {
              if (res.message){
                this.$message.error(res.message);
              }else{
                this.$message.error("操作失败");
              }
            }
          },
          error => {
            console.log(error);
          }
        );
      },
      trackPrintlabelChrornopost(){
        if (!this.waybillNos){
          this.$message.error("请输入运单号")
        }
        if (!this.accountNo){
          this.$message.error("请选择打单帐号")
        }
        if (!this.addressCode){
          this.$message.error("请选择发件人地址")
        }
        ajax("trackPrintlabelChrornopost", {waybillNos:this.waybillNos,accountNo:this.accountNo,addressCode:this.addressCode}).then(
          res => {
            console.log(res);
            if (res.code == 200) {
              this.waybillNos = null;
              this.$message.success("获取成功！");
            } else {
              this.$message.error("获取失败，" + res.message);
            }
          },
          error => {
            console.log(error);
            this.$message.error("获取失败，" + error.message);
          }
        );
      },



    },
  };
</script>
<style>
</style>
